package registnet.records;

import resources.Constants;

public class CourseTaken extends AbstractCourse {

	private Student student;
	private int semesterTaken;
	private int yearTaken;
	private Section section;
	private int credit;
	private double grade;
	private double reExam;
	private String remarks;
	
	
	/**
	 * Default constructor
	 */
	public CourseTaken(){}
	
	
	/**
	 * Constructs a CourseTaken with the given parameters
	 * 
	 * @param student - The student who took the course
	 * @param courseCode - The code assigned to the course
	 * @param section - The section in which the course was taken
	 * @param semesterTaken - The semester when the course was taken
	 * @param yearTaken - The year when the course was taken
	 */
	public CourseTaken(Student student, String courseCode, Section section, int semesterTaken, int yearTaken){
		this.student = student;
		this.courseCode = courseCode;
		this.section = section;
		this.semesterTaken = semesterTaken;
		this.yearTaken = yearTaken;
	}
	
	
	/**
	 * Constructs a CourseTaken with the given parameters
	 * 
	 * @param student - The student who took the course
	 * @param courseCode - The code assigned to the course
	 * @param semesterTaken - The semester when the course was taken
	 * @param yearTaken - The year when the course was taken
	 */
	public CourseTaken(Student student, String courseCode, int semesterTaken, int yearTaken){
		this.student = student;
		this.courseCode = courseCode;
		this.semesterTaken = semesterTaken;
		this.yearTaken = yearTaken;
	}
	
	/**
	 * Gets the student who took the course
	 * 
	 * @return	The student who took the course
	 */
	public Student getStudent() {
		return student;
	}
	
	
	/**
	 * Sets the student who took the course
	 * 
	 * @param student
	 */
	public void setStudent(Student student) {
		this.student = student;
	}
	
	
	/**
	 * Gets the semester when the course was taken
	 * 
	 * @return	The semester when the course was taken
	 */
	public int getSemesterTaken() {
		return semesterTaken;
	}
	
	
	/**
	 * Sets the semester when the course was taken
	 * 
	 * @param semesterTaken - The semester when the course was taken
	 */
	public void setSemesterTaken(int semesterTaken) {
		this.semesterTaken = semesterTaken;
	}
	
	
	/**
	 * Gets the year when the course was taken
	 * 
	 * @return	The year when the course was taken
	 */
	public int getYearTaken() {
		return yearTaken;
	
	}
	
	
	/**
	 * Sets the year when the course was taken
	 * 
	 * @param yearTaken - The year when the course was taken
	 */
	public void setYearTaken(int yearTaken) {
		this.yearTaken = yearTaken;
	}
	
	
	/**
	 * Gets the section of the course taken
	 * 
	 * @return	The section of the course taken
	 */
	public Section getSection() {
		return section;
	}
	
	
	/**
	 * Sets the section of the course taken
	 * 
	 * @param section - The section of the course taken
	 */
	public void setSection(Section section) {
		this.section = section;
	}
	
	
	/**
	 * Gets the credit for taking the course
	 * 
	 * @return	The credit for taking the course
	 */
	public int getCredit() {
		return credit;
	}
	
	
	/**
	 * Sets the credit for taking the course
	 * 
	 * @param credit - The credit for taking the course
	 */
	public void setCredit(int credit) {
		this.credit = credit;
	}
	
	
	/**
	 * Gets the grade of the course taken
	 * 
	 * @return - The grade of the course taken
	 */
	public double getGrade() {
		return grade;
	}
	
	
	/**
	 * Sets the grade of the course taken
	 * 
	 * @param grade - The grade of the course taken
	 */
	public void setGrade(double grade) {
		this.grade = grade;
	}
	
	
	/**
	 * Gets the removal/completion grade of the course taken
	 * 
	 * @return The removal/completion grade of the course taken
	 */
	public double getReExam() {
		return reExam;
	}
	
	
	/**
	 * Sets the removal/completion grade of the course taken
	 * 
	 * @param reExam - The removal/completion grade of the course taken
	 */
	public void setReExam(double reExam) {
		this.reExam = reExam;
	}
	
	
	/**
	 * Gets the remarks received from the course taken
	 * 
	 * @return - The remarks received from the course taken
	 */
	public String getRemarks() {
		return remarks;
	}
	
	
	/**
	 * Sets the remarks received from the course taken
	 * 
	 * @param remarks - The remarks received from the course taken
	 */
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	
	public boolean isCompleted(){
		if (this.reExam == 0){
			if (this.grade != Constants.MAP_GRADE_KEY.get("4") && this.grade != Constants.MAP_GRADE_KEY.get("5") && this.grade != Constants.MAP_GRADE_KEY.get("INC.") && this.grade != Constants.MAP_GRADE_KEY.get("U"))
				return true;
			else
				return false;
		}
		else{
			if (this.reExam != Constants.MAP_GRADE_KEY.get("4") && this.reExam != Constants.MAP_GRADE_KEY.get("5") && this.reExam != Constants.MAP_GRADE_KEY.get("INC.") && this.reExam != Constants.MAP_GRADE_KEY.get("U"))
				return true;
			else
				return false;
		}
	}
	
}
